# package
import cv2
from PIL import Image
import numpy as np
from .algorithms import resize, changeChannels, algo
from .basic import f_contours, Con_area, Con_perimeter, approximate_contours, feature, OCR, remap, calcHist, perspective, edge
from .pre import blur, rotate, clip, threshold, denosing, morphology

OPERATIONS = {
    'resize': resize,
    'changeChannels': changeChannels,
    'threshold': threshold,
    'contour': f_contours,
    'Con_area': Con_area,
    'Con_perimeter': Con_perimeter,
    'approximate_contours': approximate_contours,
    'blur': blur,
    'feature': feature,
    'denoising': denosing,
    'morphology': morphology,
    'rotate': rotate,
    'clip': clip,
    'OCR': OCR,
    'ai': algo,
    'remap': remap,
    'hist': calcHist,
    'perspective': perspective,
    'edge': edge
}

def bin2CV(img):
    img = Image.open(img)
    img = cv2.cvtColor(np.asarray(img), cv2.COLOR_RGB2BGR)
    return img
